import { defineStore } from 'pinia';
import localforage from 'localforage';

export const useIndexedDBStore = defineStore('indexedDB', {
  state: () => ({
    /* 存储用户上传的图片 */
    test: localforage.createInstance({
      name: 'test',
    }),
  }),
  actions: {
    save(key: string, value: any) {
      this.test.setItem(key, value);
    },
  },
  getters: {
    get(state) {
      return state.test;
    },
  },
  persist: true,
});
